function [h1,x1] = lpcvd_1DSurface_aggregate(h0,x0,agg_length)
% Aggregate every AGG_LENGTH points. If AGG_LENGTH is odd, then the median
% point is used. If AGG_LENGTH is even, the lower median is used.
% The point #ceil(agg_length/2) is kept.

x1 = (x0(ceil(agg_length/2):agg_length:end));
h1 = zeros(size(x1));
for i = 1:(length(x1)-1)
    h1(i) = mean(h0(((i-1)*agg_length+1):(i*agg_length)));
end
h1(length(x1)) = mean(h0((length(x1)-1)*agg_length+1:end));